package org.oliver.crp.samtrack.client.ui.widgets;

import org.oliver.crp.samtrack.client.ui.data.NavigationPaneRecord;

import com.google.gwt.core.client.GWT;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.VisibilityMode;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
import com.smartgwt.client.widgets.layout.SectionStack;
import com.smartgwt.client.widgets.layout.SectionStackSection;
import com.smartgwt.client.widgets.layout.VLayout;

public class NavigationPane extends VLayout {
	
  private static final int WEST_WIDTH = 200;
  private SectionStack sectionStack;
	  	
  public NavigationPane() {
    super();
				
    GWT.log("init Navigation Pane()...", null);
			
    // initialise the layout container
    this.setWidth(WEST_WIDTH);
    this.addStyleName("crm-NavigationPane");
    
    sectionStack = new SectionStack();
    sectionStack.setWidth(WEST_WIDTH);
    sectionStack.setVisibilityMode(VisibilityMode.MUTEX);
    sectionStack.setShowExpandControls(true);
    sectionStack.setAnimateSections(true);
    
    this.addMember(sectionStack);
    
//    String sample = "New Sample<br/>Show MySamples<br/>Add Data";
//    String edit = "Edit Sample<br/>Edit Data<br/>";
//    String search = "Search Samples<br/>Search Data<br/>";
//    String reports = "Generate Report<br/>";
//    String administration = "Edit User<br/>";
//    
//    // init Sample section
//    SectionStackSection section1 = new SectionStackSection("Sample");
//    section1.setExpanded(true);
//    HTMLFlow htmlFlow1 = new HTMLFlow();
//    htmlFlow1.setOverflow(Overflow.AUTO);
//    htmlFlow1.setPadding(10);
//    htmlFlow1.setContents(sample);
//    section1.addItem(htmlFlow1);
//    // init Edit section
//    SectionStackSection section2 = new SectionStackSection("Edit");
//    section2.setExpanded(true);
//    HTMLFlow htmlFlow2 = new HTMLFlow();
//    htmlFlow2.setOverflow(Overflow.AUTO);
//    htmlFlow2.setPadding(10);
//    htmlFlow2.setContents(edit);
//    section2.addItem(htmlFlow2);
//    // init Reports section
//    SectionStackSection section3 = new SectionStackSection("Reports");
//    section3.setExpanded(true);
//    HTMLFlow htmlFlow3 = new HTMLFlow();
//    htmlFlow3.setOverflow(Overflow.AUTO);
//    htmlFlow3.setPadding(10);
//    htmlFlow3.setContents(reports);
//    section3.addItem(htmlFlow3);
//    
//    this.addSection(section1);
//    this.addSection(section2);
//    this.addSection(section3);
  }	
  
  public void add(String sectionName, NavigationPaneRecord[] sectionData, RecordClickHandler clickHandler) {
	  sectionStack.addSection(new NavigationPaneSection(sectionName, sectionData, clickHandler));
  }
  public void expandSection(int section) {
	  sectionStack.expandSection(section);
  }
}

